﻿@using Kevin.Shop.Business.SalesManagement.Enumerations
@model  RiderShop.Mobile.Modle.Purchase.CheckOutModel
@{
    ViewBag.Title = "OrderComplete";
}
@{
    Layout = null;
}
<html>
<head>
    <title>微团购</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <meta http-equiv="Content-Type" content="application/xhtml+xml;charset=UTF-8">
    <meta http-equiv="Cache-Control" content="no-cache,must-revalidate">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta name="format-detection" content="telephone=no, address=no">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="http://dev.pupuxing.net/BaseData/GroupBy/css/main.css">
    <link rel="stylesheet" href="~/Themes/RongJi/Style/base/css/common.css">
    <script src="http://dev.pupuxing.net/BaseData/GroupBy/js/hidewxmenu.js"></script>
    <script type="text/javascript" src="http://dev.pupuxing.net/assets/plugins/jquery-1.10.2.min.js"> </script>
    <script type="text/javascript" src="http://m.rongji365.com/Utility/pages/pg_common.js" charset="gb2312"></script>

    <style type="text/css">
        body, html {
            height: 100%;
        }

        .container {
            max-width: 640px;
            margin: auto;
            min-height: 100%;
            position: relative;
            color: #5d5d5d;
        }

        .pay_box {
            /*position: absolute;
            left: 0;
            top: 50%;
            margin-top: -130px;*/
            width: 100%;
            font-size: 14px;
            text-align: center;
            padding: 0 16px;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
        }

        .pay_box1 {
            /*position: absolute;
            left: 0;
            top: 40%;
            margin-top: -100px;*/
            width: 100%;
            font-size: 14px;
            text-align: center;
            padding: 0 16px;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
        }

        .form-control {
            display: block;
            width: 100%;
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #434a54;
            background-color: #fff;
            background-image: none;
            border: 1px solid #aab2bd;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
            transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
        }

            .form-control, .form-control:focus {
                -webkit-box-shadow: none;
                -moz-box-shadow: none;
                box-shadow: none;
            }

        .pay_box p {
            margin: 5px 0;
        }

        .pay_box h3 {
            font-size: 24px;
            margin: 40px 0 40px;
        }

            .pay_box h3 strong {
                color: #f17a2b;
                margin-left: 10px;
            }

        .btn {
            display: block;
            width: 100%;
            height: 47px;
            line-height: 47px;
            font-size: 18px;
            text-decoration: none;
            background-color: #23ad65;
            color: #fff;
        }

        .success_box {
            margin-top: -135px;
        }

            .success_box h3 {
                margin: 40px 0 40px;
            }
    </style>
</head>
<body>
    <div class="gbuy_payState container">
        <div id="container" class="container animate">
            <header></header>
            <div class="body">
                <section class="section_pay pay_success">
                    @if (Model.OrderResult.Status)
                    {
                        <article>
                            <header>
                                <label>
                                    <span class="icons icons_success">&nbsp;</span><span style="font-size:20px;">恭喜您，请用9.99元获取礼品</span>
                                </label>
                            </header>

                            <div class="tip">
                                请输入领取人姓名：
                            </div>
                            <div class="pay_box1">
                                <input name="name" id="username" class="form-control" />
                            </div>

                            <div class="tip">
                                请输入领取人电话：
                            </div>
                            <div class="pay_box1">
                                <input name="tel" type="telephone" id="tel" class="form-control" />
                            </div>
                            <div class="tip">
                                请选择领取地址：
                            </div>
                            <div class="pay_box1">
                                <select id="shippaddress" name="shippaddress" class="select">
                                    <option value="1672">民生家乐科技路店</option>
                                    <option value="1673">民生家乐丈八路店</option>
                                    <option value="1674">民生家乐文景路店</option>
                                </select>
                                <input type="hidden" id="txtOrderNumber" value="@Model.CurrentOrder.OrderNumber.Trim()" />
                            </div>
                            <div class="pay_box">
                                @if (Model.CurrentOrder.OrderStatus == OrderStatus.待支付)
                                {
                                    <h3>金额：<strong>￥9.99</strong></h3>
                                    <p><label>付款方式：</label><span class="blue f14">微信支付</span></p>
                                    <p><a id="btnsubmitOrder" href="#" class="btn">立即付款</a></p>
                                }
                                <form id="submitShipping" method="POST" action="~/Purchase/UpdateOrderShipping"></form>
                                <form id="weixinPay" method="GET" action="@(string.Format(System.Configuration.ConfigurationManager.AppSettings["WeixinPayAddress"], @Model.CurrentOrder.OrderNumber.Trim()))"></form>
                            </div>
                        </article>
                    }
                    else
                    {
                        <article>
                            <header>
                                <label>
                                    <span>@Model.OrderResult.ErrorMessage</span>
                                </label>
                            </header>

                        </article>
                    }
                </section>
            </div>
            @*<footer>
                    <section class="header_nav">
                        <ul class="tbox">
                            <li><a href="javascript:history.go(-1);" class="icons icons_back" style="background-color: rgba(0, 151,177,1);">&nbsp;</a></li>
                            <li><a href=@Html.Raw(string.Format("http://m.rongji365.com/WeixinPortal/Activity/QingRenJieRank?id=179&portal=rongji365&pid={0}",Request.QueryString["pid"])) class="btn">查看我的排名</a></li>
                        </ul>
                    </section>
                </footer>*@
        </div>
    </div>

    <script type="text/javascript" language="javascript">
        $(document).ready(function () {

            $("#btnsubmitOrder").click(function () {

                var shippingId = $("#shippaddress").val();
                var tel = $("#tel").val();
                var name = $("#username").val();
                if (!name) {
                    alert("请输入领奖人姓名！");
                    return;
                }
                if (!tel) {
                    alert("请输入领奖人电话！");
                    return;
                }
                var orderNumber = $("#txtOrderNumber").val();
                var url = document.forms["submitShipping"].action;

                url = encodeURI(url + "?shippingId=" + shippingId + "&orderNumber=" + orderNumber + "&tel=" + tel + "&name=" + name);
                // alert(url);
                KevinShop.Common.Ajax.Get(url, function (data) {
                    if (data.error) {
                        alert(data.error);
                        return;
                    }

                    if (!data.Status) {
                        alert(data.ErrorMessage);
                        return;
                    }
                    var completeUrl = document.forms["weixinPay"].action;
                    window.location = completeUrl;
                    //alert(completeUrl);
                }, false);
            });

            $.post("http://m.rongji365.com/WeixinJsSdk/ConfigScriptJson", postData, function (wxConfig) {

                wxConfig.jsApiList.push("hideOptionMenu");
                wx.config(wxConfig);

                wx.ready(function () {
                    // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。

                    wx.hideOptionMenu();
                });

                wx.error(function (res) {
                    // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。

                });
            });
        });
        function onBridgeReady() {
            WeixinJSBridge.call('hideOptionMenu');
        }

        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    </script>
</body>
</html>